package com.ruoyi.boat.controller;

import com.ruoyi.boat.aop.AvoidDuplicate;
import com.ruoyi.boat.domain.TStxData;
import com.ruoyi.boat.service.ITStxDataService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * 声通信数据Controller
 * 
 * @author ruoyi
 * @date 2024-07-11
 */
@Controller
@RequestMapping("/boat/sxt")
public class TStxDataController extends BaseController
{
    private String prefix = "boat/sxt";

    @Autowired
    private ITStxDataService tStxDataService;

    @RequiresPermissions("boat:sxt:view")
    @GetMapping()
    public String sxt()
    {
        return prefix + "/sxt";
    }

    /**
     * 查询声通信数据列表
     */
    @RequiresPermissions("boat:sxt:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TStxData tStxData)
    {
        startPage();
        List<TStxData> list = tStxDataService.selectTStxDataList(tStxData);
        return getDataTable(list);
    }

    /**
     * 导出声通信数据列表
     */
    @RequiresPermissions("boat:sxt:export")
    @Log(title = "声通信数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TStxData tStxData)
    {
        List<TStxData> list = tStxDataService.selectTStxDataList(tStxData);
        ExcelUtil<TStxData> util = new ExcelUtil<>(TStxData.class);
        return util.exportExcel(list, "声通信数据数据");
    }

    /**
     * 新增声通信数据
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存声通信数据
     */
    @RequiresPermissions("boat:sxt:add")
    @Log(title = "声通信数据", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TStxData tStxData)
    {
        return toAjax(tStxDataService.insertTStxData(tStxData));
    }

    /**
     * 修改声通信数据
     */
    @RequiresPermissions("boat:sxt:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TStxData tStxData = tStxDataService.selectTStxDataById(id);
        mmap.put("tStxData", tStxData);
        return prefix + "/edit";
    }

    /**
     * 修改保存声通信数据
     */
    @RequiresPermissions("boat:sxt:edit")
    @Log(title = "声通信数据", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TStxData tStxData)
    {
        return toAjax(tStxDataService.updateTStxData(tStxData));
    }

    /**
     * 删除声通信数据
     */
    @RequiresPermissions("boat:sxt:remove")
    @Log(title = "声通信数据", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tStxDataService.deleteTStxDataByIds(ids));
    }
}
